<?php
// 本类由系统自动生成，仅供测试用途
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {

    //主页   
    public function index(){
    	$c   = $this->c;
        $uid = $this->uid; //微博用户UID
        $user_message = $c->show_user_by_id( $uid);//根据ID获取用户等基本信息
        session('weiboname',$user_message['screen_name']); //微博用户名存到session        
        session('avatar',$user_message['profile_image_url']); //用户头像地址存到session        
        //如果用户使用本地账号登陆
        if(isset($_SESSION['id'])){
            $db = M('user');
            $data['uid'] = $uid;
            $data['id']  = $_SESSION['id'];
            $db->save($data);
        }
        $this->message =$user_message;
        //传递微博列表到模板
        $this ->ms  = $c->home_timeline(); 
        //获取正在是用的用户
        $db = M('user');

		$this->display();
    }


    //用户登出
    public function logout(){
    	session(null); 
    	redirect(__APP__.'/User');
    }
    
}